from make_data.models.DIct import Dict


# 不使用规则文件造数，同时返回规则文件
class DataWithOutRuleStrComponent:
    def __init__(self, column_num, data_rule, data_str, split_str):
        self.column_num = column_num
        self.data_rule = data_rule
        self.data_str = data_str
        self.split_str = split_str

    def get_data_with_rule_str(self):
        self.data_rule += self.split_str + " "
        i = 0
        for _ in range(int(self.column_num)):
            i += 1
            type_num = input("请选择第" + str(i) + "个字段的具体分类: " + Dict.choice_message)
            self.data_rule += type_num + " "
            value: str = input(Dict.navigation_dict[type_num])
            self.data_rule += value + " "
            self.data_str += eval(Dict.menu_dict[type_num]) + "+'" + self.split_str + "'+"
        return self.data_rule, self.data_str


# 使用规则文件造数 读取规则返回造数字符串
class DataWithRuleStrComponent:
    def __init__(self, column_num, column_type_rule, column_detail_rule, split_str, data_str):
        self.column_num = column_num
        self.column_type_rule = column_type_rule
        self.column_detail_rule = column_detail_rule
        self.split_str = split_str
        self.data_str = data_str

    def get_data_str(self):
        i = 0
        j = 0
        for _ in range(int(self.column_num)):
            type_num = self.column_type_rule[i]
            value = self.column_detail_rule[j]
            print("请选择第" + str(i + 1) + "个字段的具体分类: " + Dict.choice_message)
            print(Dict.navigation_dict[type_num] + value)
            self.data_str += eval(Dict.menu_dict[type_num]) + "+'" + self.split_str + "'+"
            i += 1
            j += 1
        return self.data_str
